import config from '@/core/config/index.js'
import {
	checkLogin
} from '../app'
export default {
	data() {
		return {
			share: {
				// 转发的标题 （默认标题）
				title: config.get('name'),
				// 默认是当前页面，必须是以‘/’开头的完整路径
				path: `/pages/home/index`,
				//自定义图片路径，可以是本地文件路径、代码包文件路径或者网络图片路径，
				//支持PNG及JPG，不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
				imageUrl: config.get('logo')
			}
		}
	},
	// 发送给朋友
	onShareAppMessage(res) {
		let shareInfo = uni.getStorageSync('shareInfo')
		return {
			title: shareInfo.title || this.share.title,
			imageUrl: shareInfo.imageUrl || this.share.imageUrl,
			path: shareInfo.path || this.share.path,
			complete: shareInfo.complete ? shareInfo.complete() : () => uni.removeStorageSync('shareInfo')
		}
	},
	//分享到朋友圈
	onShareTimeline(res) {
		let shareInfo = uni.getStorageSync('shareInfo')
		if (checkLogin()) {
			let storeInfo = uni.getStorageSync('userInfo-banjia')
			if (storeInfo.id) shareInfo.path += `&parent_id=${storeInfo.id}`
		}
		return {
			title: shareInfo.title || this.share.title,
			imageUrl: shareInfo.imgUrl || this.share.imageUrl,
			path: shareInfo.path || this.share.path,
			complete: shareInfo.complete ? shareInfo.complete() : () => uni.removeStorageSync('shareInfo')
		}
	},
}